.TH std::ostream_iterator::operator= 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::ostream_iterator::operator= \- std::ostream_iterator::operator=

.SH Synopsis
   ostream_iterator& operator=( const ostream_iterator& ); \fB(1)\fP
   ostream_iterator& operator=( const T& value );          \fB(2)\fP

   1) Copy assignment operator. Assigns the contents of other
   2) Inserts value into the associated stream, then inserts the delimiter, if one was
   specified at construction time.

   If out_stream is a pointer to the associated std::basic_ostream and delim is the
   delimiter specified at the construction of this object, then the effect is
   equivalent to

   *out_stream << value;
   if (delim != 0)
       *out_stream << delim;
   return *this;

.SH Parameters

   value - the object to insert

.SH Return value

   *this

.SH Notes

   T can be any class with a user-defined operator<<.

   Prior to C++20, the existence of the copy assignment operator relied on the
   deprecated implicit generation.

.SH Example


// Run this code

 #include <iostream>
 #include <iterator>

 int main()
 {
     std::ostream_iterator<int> i1(std::cout, ", ");
     *i1++ = 1; // usual form, used by standard algorithms
     *++i1 = 2;
     i1 = 3; // neither * nor ++ are necessary
     std::ostream_iterator<double> i2(std::cout);
     i2 = 3.14;
     std::cout << '\\n';
 }

.SH Output:

 1, 2, 3, 3.14
